package spem.activity.diagram.part;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.View;

import spem.Activity;
import spem.ControlFlow;
import spem.Decision;
import spem.Element;
import spem.RoleDefinition;
import spem.SpemPackage;
import spem.Step;
import spem.TaskDefinition;
import spem.Tool;
import spem.WorkProductDefinition;
import spem.activity.diagram.edit.parts.Activity2EditPart;
import spem.activity.diagram.edit.parts.ActivityEditPart;
import spem.activity.diagram.edit.parts.ControlFlowEditPart;
import spem.activity.diagram.edit.parts.DecisionEditPart;
import spem.activity.diagram.edit.parts.RoleDefinitionEditPart;
import spem.activity.diagram.edit.parts.RoleDefinitionPerformsEditPart;
import spem.activity.diagram.edit.parts.Step2EditPart;
import spem.activity.diagram.edit.parts.TaskDefinitionEditPart;
import spem.activity.diagram.edit.parts.TaskDefinitionInputEditPart;
import spem.activity.diagram.edit.parts.TaskDefinitionOutputEditPart;
import spem.activity.diagram.edit.parts.TaskDefinitionTaskStepCompartmentEditPart;
import spem.activity.diagram.edit.parts.TaskDefinitionUsesEditPart;
import spem.activity.diagram.edit.parts.ToolEditPart;
import spem.activity.diagram.edit.parts.WorkProductDefinitionEditPart;
import spem.activity.diagram.providers.SpemElementTypes;

/**
 * @generated
 */
public class SpemDiagramUpdater {

	/**
	 * @generated
	 */
	public static List<SpemNodeDescriptor> getSemanticChildren(View view) {
		switch (SpemVisualIDRegistry.getVisualID(view)) {
		case ActivityEditPart.VISUAL_ID:
			return getActivity_1000SemanticChildren(view);
		case TaskDefinitionTaskStepCompartmentEditPart.VISUAL_ID:
			return getTaskDefinitionTaskStepCompartment_7001SemanticChildren(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<SpemNodeDescriptor> getActivity_1000SemanticChildren(
			View view) {
		if (!view.isSetElement()) {
			return Collections.emptyList();
		}
		Activity modelElement = (Activity) view.getElement();
		LinkedList<SpemNodeDescriptor> result = new LinkedList<SpemNodeDescriptor>();
		for (Iterator<?> it = modelElement.getNestedElements().iterator(); it
				.hasNext();) {
			Element childElement = (Element) it.next();
			int visualID = SpemVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == WorkProductDefinitionEditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == RoleDefinitionEditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == Activity2EditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == DecisionEditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == TaskDefinitionEditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == ToolEditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemNodeDescriptor> getTaskDefinitionTaskStepCompartment_7001SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		TaskDefinition modelElement = (TaskDefinition) containerView
				.getElement();
		LinkedList<SpemNodeDescriptor> result = new LinkedList<SpemNodeDescriptor>();
		for (Iterator<?> it = modelElement.getSteps().iterator(); it.hasNext();) {
			Step childElement = (Step) it.next();
			int visualID = SpemVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == Step2EditPart.VISUAL_ID) {
				result.add(new SpemNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getContainedLinks(View view) {
		switch (SpemVisualIDRegistry.getVisualID(view)) {
		case ActivityEditPart.VISUAL_ID:
			return getActivity_1000ContainedLinks(view);
		case WorkProductDefinitionEditPart.VISUAL_ID:
			return getWorkProductDefinition_2001ContainedLinks(view);
		case RoleDefinitionEditPart.VISUAL_ID:
			return getRoleDefinition_2002ContainedLinks(view);
		case Activity2EditPart.VISUAL_ID:
			return getActivity_2003ContainedLinks(view);
		case DecisionEditPart.VISUAL_ID:
			return getDecision_2004ContainedLinks(view);
		case TaskDefinitionEditPart.VISUAL_ID:
			return getTaskDefinition_2005ContainedLinks(view);
		case ToolEditPart.VISUAL_ID:
			return getTool_2006ContainedLinks(view);
		case Step2EditPart.VISUAL_ID:
			return getStep_3001ContainedLinks(view);
		case ControlFlowEditPart.VISUAL_ID:
			return getControlFlow_4001ContainedLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getIncomingLinks(View view) {
		switch (SpemVisualIDRegistry.getVisualID(view)) {
		case WorkProductDefinitionEditPart.VISUAL_ID:
			return getWorkProductDefinition_2001IncomingLinks(view);
		case RoleDefinitionEditPart.VISUAL_ID:
			return getRoleDefinition_2002IncomingLinks(view);
		case Activity2EditPart.VISUAL_ID:
			return getActivity_2003IncomingLinks(view);
		case DecisionEditPart.VISUAL_ID:
			return getDecision_2004IncomingLinks(view);
		case TaskDefinitionEditPart.VISUAL_ID:
			return getTaskDefinition_2005IncomingLinks(view);
		case ToolEditPart.VISUAL_ID:
			return getTool_2006IncomingLinks(view);
		case Step2EditPart.VISUAL_ID:
			return getStep_3001IncomingLinks(view);
		case ControlFlowEditPart.VISUAL_ID:
			return getControlFlow_4001IncomingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getOutgoingLinks(View view) {
		switch (SpemVisualIDRegistry.getVisualID(view)) {
		case WorkProductDefinitionEditPart.VISUAL_ID:
			return getWorkProductDefinition_2001OutgoingLinks(view);
		case RoleDefinitionEditPart.VISUAL_ID:
			return getRoleDefinition_2002OutgoingLinks(view);
		case Activity2EditPart.VISUAL_ID:
			return getActivity_2003OutgoingLinks(view);
		case DecisionEditPart.VISUAL_ID:
			return getDecision_2004OutgoingLinks(view);
		case TaskDefinitionEditPart.VISUAL_ID:
			return getTaskDefinition_2005OutgoingLinks(view);
		case ToolEditPart.VISUAL_ID:
			return getTool_2006OutgoingLinks(view);
		case Step2EditPart.VISUAL_ID:
			return getStep_3001OutgoingLinks(view);
		case ControlFlowEditPart.VISUAL_ID:
			return getControlFlow_4001OutgoingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getActivity_1000ContainedLinks(
			View view) {
		Activity modelElement = (Activity) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getWorkProductDefinition_2001ContainedLinks(
			View view) {
		WorkProductDefinition modelElement = (WorkProductDefinition) view
				.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getRoleDefinition_2002ContainedLinks(
			View view) {
		RoleDefinition modelElement = (RoleDefinition) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_RoleDefinition_Performs_4002(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getActivity_2003ContainedLinks(
			View view) {
		Activity modelElement = (Activity) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getDecision_2004ContainedLinks(
			View view) {
		Decision modelElement = (Decision) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getTaskDefinition_2005ContainedLinks(
			View view) {
		TaskDefinition modelElement = (TaskDefinition) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_TaskDefinition_Input_4003(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_TaskDefinition_Uses_4004(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_TaskDefinition_Output_4005(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getTool_2006ContainedLinks(View view) {
		Tool modelElement = (Tool) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getStep_3001ContainedLinks(View view) {
		Step modelElement = (Step) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getControlFlow_4001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getWorkProductDefinition_2001IncomingLinks(
			View view) {
		WorkProductDefinition modelElement = (WorkProductDefinition) view
				.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		result.addAll(getIncomingFeatureModelFacetLinks_TaskDefinition_Input_4003(
				modelElement, crossReferences));
		result.addAll(getIncomingFeatureModelFacetLinks_TaskDefinition_Output_4005(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getRoleDefinition_2002IncomingLinks(
			View view) {
		RoleDefinition modelElement = (RoleDefinition) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getActivity_2003IncomingLinks(
			View view) {
		Activity modelElement = (Activity) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getDecision_2004IncomingLinks(
			View view) {
		Decision modelElement = (Decision) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getTaskDefinition_2005IncomingLinks(
			View view) {
		TaskDefinition modelElement = (TaskDefinition) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		result.addAll(getIncomingFeatureModelFacetLinks_RoleDefinition_Performs_4002(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getTool_2006IncomingLinks(View view) {
		Tool modelElement = (Tool) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		result.addAll(getIncomingFeatureModelFacetLinks_TaskDefinition_Uses_4004(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getStep_3001IncomingLinks(View view) {
		Step modelElement = (Step) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_ControlFlow_4001(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getControlFlow_4001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getWorkProductDefinition_2001OutgoingLinks(
			View view) {
		WorkProductDefinition modelElement = (WorkProductDefinition) view
				.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getRoleDefinition_2002OutgoingLinks(
			View view) {
		RoleDefinition modelElement = (RoleDefinition) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_RoleDefinition_Performs_4002(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getActivity_2003OutgoingLinks(
			View view) {
		Activity modelElement = (Activity) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getDecision_2004OutgoingLinks(
			View view) {
		Decision modelElement = (Decision) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getTaskDefinition_2005OutgoingLinks(
			View view) {
		TaskDefinition modelElement = (TaskDefinition) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_TaskDefinition_Input_4003(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_TaskDefinition_Uses_4004(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_TaskDefinition_Output_4005(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getTool_2006OutgoingLinks(View view) {
		Tool modelElement = (Tool) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getStep_3001OutgoingLinks(View view) {
		Step modelElement = (Step) view.getElement();
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_ControlFlow_4001(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<SpemLinkDescriptor> getControlFlow_4001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getContainedTypeModelFacetLinks_ControlFlow_4001(
			Element container) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		for (Iterator<?> links = container.getFlows().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof ControlFlow) {
				continue;
			}
			ControlFlow link = (ControlFlow) linkObject;
			if (ControlFlowEditPart.VISUAL_ID != SpemVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			Element dst = link.getSource();
			result.add(new SpemLinkDescriptor(container, dst, link,
					SpemElementTypes.ControlFlow_4001,
					ControlFlowEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getIncomingTypeModelFacetLinks_ControlFlow_4001(
			Element target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != SpemPackage.eINSTANCE
					.getControlFlow_Source()
					|| false == setting.getEObject() instanceof ControlFlow) {
				continue;
			}
			ControlFlow link = (ControlFlow) setting.getEObject();
			if (ControlFlowEditPart.VISUAL_ID != SpemVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			if (false == link.eContainer() instanceof Element) {
				continue;
			}
			Element container = (Element) link.eContainer();
			result.add(new SpemLinkDescriptor(container, target, link,
					SpemElementTypes.ControlFlow_4001,
					ControlFlowEditPart.VISUAL_ID));

		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getIncomingFeatureModelFacetLinks_RoleDefinition_Performs_4002(
			TaskDefinition target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == SpemPackage.eINSTANCE
					.getRoleDefinition_Performs()) {
				result.add(new SpemLinkDescriptor(setting.getEObject(), target,
						SpemElementTypes.RoleDefinitionPerforms_4002,
						RoleDefinitionPerformsEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getIncomingFeatureModelFacetLinks_TaskDefinition_Input_4003(
			WorkProductDefinition target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == SpemPackage.eINSTANCE
					.getTaskDefinition_Input()) {
				result.add(new SpemLinkDescriptor(setting.getEObject(), target,
						SpemElementTypes.TaskDefinitionInput_4003,
						TaskDefinitionInputEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getIncomingFeatureModelFacetLinks_TaskDefinition_Uses_4004(
			Tool target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == SpemPackage.eINSTANCE
					.getTaskDefinition_Uses()) {
				result.add(new SpemLinkDescriptor(setting.getEObject(), target,
						SpemElementTypes.TaskDefinitionUses_4004,
						TaskDefinitionUsesEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getIncomingFeatureModelFacetLinks_TaskDefinition_Output_4005(
			WorkProductDefinition target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == SpemPackage.eINSTANCE
					.getTaskDefinition_Output()) {
				result.add(new SpemLinkDescriptor(setting.getEObject(), target,
						SpemElementTypes.TaskDefinitionOutput_4005,
						TaskDefinitionOutputEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getOutgoingFeatureModelFacetLinks_RoleDefinition_Performs_4002(
			RoleDefinition source) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		for (Iterator<?> destinations = source.getPerforms().iterator(); destinations
				.hasNext();) {
			TaskDefinition destination = (TaskDefinition) destinations.next();
			result.add(new SpemLinkDescriptor(source, destination,
					SpemElementTypes.RoleDefinitionPerforms_4002,
					RoleDefinitionPerformsEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getOutgoingFeatureModelFacetLinks_TaskDefinition_Input_4003(
			TaskDefinition source) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		for (Iterator<?> destinations = source.getInput().iterator(); destinations
				.hasNext();) {
			WorkProductDefinition destination = (WorkProductDefinition) destinations
					.next();
			result.add(new SpemLinkDescriptor(source, destination,
					SpemElementTypes.TaskDefinitionInput_4003,
					TaskDefinitionInputEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getOutgoingFeatureModelFacetLinks_TaskDefinition_Uses_4004(
			TaskDefinition source) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		Tool destination = source.getUses();
		if (destination == null) {
			return result;
		}
		result.add(new SpemLinkDescriptor(source, destination,
				SpemElementTypes.TaskDefinitionUses_4004,
				TaskDefinitionUsesEditPart.VISUAL_ID));
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<SpemLinkDescriptor> getOutgoingFeatureModelFacetLinks_TaskDefinition_Output_4005(
			TaskDefinition source) {
		LinkedList<SpemLinkDescriptor> result = new LinkedList<SpemLinkDescriptor>();
		for (Iterator<?> destinations = source.getOutput().iterator(); destinations
				.hasNext();) {
			WorkProductDefinition destination = (WorkProductDefinition) destinations
					.next();
			result.add(new SpemLinkDescriptor(source, destination,
					SpemElementTypes.TaskDefinitionOutput_4005,
					TaskDefinitionOutputEditPart.VISUAL_ID));
		}
		return result;
	}

}
